package com.servlet.dba;

import com.enitiy.Dba;
import com.service.dba.DbaServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 创建作者 ：MySunshine
 * 创建时间 2022/10/26 16:45
 * 项目名称 SHUSHAN
 */
@WebServlet("/DbaSelectByNum")
public class DbaSelectByNum extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String num = req.getParameter("num");
        System.out.println(num);
        DbaServiceImpl dsi = new DbaServiceImpl();
        Dba dba = dsi.DbaSelectByNum(Integer.parseInt(num));
        if (dba!=null){
            String img = dba.getImg();
            if (img==null||img.length() <= 0){
                System.out.println(img);
                img="1.jpg";
                dba.setImg(img);
            }
                System.out.println("查询成功！");
                req.setAttribute("dba",dba);
                req.getRequestDispatcher("/page/dba/dbaUpdate.jsp").forward(req,resp);
            }else {
                System.out.println("查询失败！");
            }
        }


}
